package top.stmo;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 *              模拟 HttpServlet
 */

public class MyHttpServlet implements Servlet {


    @Override
    public void init(ServletConfig servletConfig) throws ServletException {

    }

    @Override
    public ServletConfig getServletConfig() {
        return null;
    }

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse)
                                                throws ServletException, IOException {

        HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
        String method = httpServletRequest.getMethod();
        if ("GET".equals(method)) {
            doGet(servletRequest,servletResponse);
        }else if ("Post".equals(method)) {
            doPost(servletRequest,httpServletRequest);
        }

    }

    protected void doGet(ServletRequest servletRequest, ServletResponse servletResponse) {
    }

    protected void doPost(ServletRequest servletRequest,HttpServletRequest httpServletRequest) {
    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {

    }
}
